package org.nicocube.airain.gwt.client.ui;

import org.nicocube.airain.gwt.client.AirainWeb;

import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TabListener;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.Widget;

public abstract class AirainPanel {
	private AirainWeb aw;
	public AirainPanel(AirainWeb aw) {
		this.aw = aw;
	}
	public AirainWeb getAW() {
		return aw;
	}
	public abstract Widget getLabel();
	public abstract Panel getPanel();
	public TabListener getTabListener(int index){return null;}
	public void addTo(TabPanel tp) {
		Panel panel = getPanel();
		tp.add(panel, getLabel());
		int index = tp.getWidgetIndex(panel);
		TabListener tl = getTabListener(index);
		if (tl != null) tp.addTabListener(tl);
	}
}
